/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package accesoDatos;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author manuelita
 */
public class Conexion {
    protected Connection conexion;
    
    public Conexion(){
        this.conexion = null;
    }
    
    public boolean Conectar(){
        try{
            Class.forName("oracle.jdbc.driver.OracleDriver");
                this.conexion = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "manager");
            return true;
        }
        catch(SQLException ex){
            System.out.println(ex.getMessage());
            return false;
        }
        catch(ClassNotFoundException ex){
            System.out.println(ex.getMessage());
            return false;
        }
    }
    
    protected boolean Desconectar(){
        try {
            if(!this.conexion.isClosed()){
                this.conexion.close();
                return true;
            }
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
        return false;
    }
}
